package com.dragons.spring5.transaction.service;

import com.dragons.spring5.transaction.dao.AccountDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(timeout = -1,propagation = Propagation.MANDATORY,isolation = Isolation.DEFAULT)
public class AccountService {

//    @Nullable
//    private String userName;

    private static final Logger log = LoggerFactory.getLogger(AccountService.class);
    @Autowired
    private AccountDao accountDao;
    public void accountMoney() {//转账的方法
        accountDao.reduceMoney();//lucy 少 100
//        int a = 10/0;/**模拟异常*/
//        log.info("info");
//        log.debug("debug");
        accountDao.addMoney();//mary 多 100
    }
}